﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/MasterPage.master" AutoEventWireup="true" CodeFile="QuanLyLoaiSanPham.aspx.cs" Inherits="Admin_QuanLyLoaiSanPham" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server">
 <h3>Quản lý loại tài liệu</h3>	

    <asp:ListView ID="ListView1" runat="server" DataKeyNames="IDLoaiTL,TenLoaiTL,IDLoaiTLCha,ThuTuHienThi,TenLoaiTL_en,LoaiCopy"
        DataSourceID="SqlDataSource1" EnableModelValidation="True" 
        OnSelectedIndexChanging="ListView1_SelectedIndexChanging"
        >
      
        <EditItemTemplate>
            <tr style="">
                <td>
                    <asp:Button ID="UpdateButton" runat="server" CommandName="Update" 
                        Text="Update" />
                    <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" 
                        Text="Cancel" />
                </td>
                <td>
                    <asp:Label ID="IDLoaiTLLabel1" runat="server" Text='<%# Eval("IDLoaiTL") %>' />
                </td>
                <td>
                    <asp:TextBox ID="TenLoaiTLTextBox" runat="server" 
                        Text='<%# Bind("TenLoaiTL") %>' />
                </td>
                <td>
                    <asp:TextBox ID="IDLoaiTLChaTextBox" runat="server" 
                        Text='<%# Bind("IDLoaiTLCha") %>' />
                </td>
                <td>
                    <asp:TextBox ID="ThuTuHienThiTextBox" runat="server" 
                        Text='<%# Bind("ThuTuHienThi") %>' />
                </td>
                <td>
                    <asp:TextBox ID="LoaiCopyTextBox" runat="server" 
                        Text='<%# Bind("LoaiCopy") %>' />
                </td>
                <td>
                    <asp:TextBox ID="TenLoaiTL_enTextBox" runat="server" 
                        Text='<%# Bind("TenLoaiTL_en") %>' />
                </td>
                 
            </tr>
        </EditItemTemplate>
        <EmptyDataTemplate>
            <table id="Table1" runat="server" style="">
                <tr>
                    <td>
                        No data was returned.</td>
                </tr>
            </table>
        </EmptyDataTemplate>
        <InsertItemTemplate>
            <tr style="">
                <td>
                    <asp:Button ID="InsertButton" runat="server" CommandName="Insert" 
                        Text="Insert" />
                    <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" 
                        Text="Clear" />
                </td>
                <td>
                    &nbsp;</td>
                <td>
                    <asp:TextBox ID="TenLoaiTLTextBox" runat="server" 
                        Text='<%# Bind("TenLoaiTL") %>' />
                </td>
                <td>
                    <asp:TextBox ID="IDLoaiTLChaTextBox" runat="server" 
                        Text='<%# Bind("IDLoaiTLCha") %>' />
                </td>
                <td>
                    <asp:TextBox ID="ThuTuHienThiTextBox" runat="server" 
                        Text='<%# Bind("ThuTuHienThi") %>' />
                </td>
                <td>
                    <asp:TextBox ID="LoaiCopyTextBox" runat="server" 
                        Text='<%# Bind("LoaiCopy") %>' />
                </td>
                <td>
                    <asp:TextBox ID="TenLoaiTL_enTextBox" runat="server" 
                        Text='<%# Bind("TenLoaiTL_en") %>' />
                </td>
            </tr>
        </InsertItemTemplate>
        <ItemTemplate>
              <tr style="">
               
                <td>
                    <asp:Label ID="IDLoaiTLLabel" runat="server" Text='<%# Eval("IDLoaiTL") %>' />
                </td>
                <td>
                    <asp:Label ID="TenLoaiTLLabel" runat="server" 
                        Text='<%# Eval("TenLoaiTL") %>' />
                </td>
                <td>
                     <asp:Label ID="TenLoaiTL_enLabel" runat="server" 
                         Text='<%# Eval("TenLoaiTL_en") %>' />
                </td>
                <td>
                    <asp:Label ID="IDLoaiTLChaLabel" runat="server" 
                        Text='<%# Eval("IDLoaiTLCha") %>' />
                </td>
               
                 
                 <td>
                    <asp:ImageButton ID="Button3" runat="server" CommandName="Select" ImageUrl="~/Admin/images/edit.png"
                        Text="Edit" />
                     <asp:ImageButton ID="Button1" runat="server" CommandName="Delete" ImageUrl="~/Admin/images/drop.png"
                        Text="Del" />
                </td>
               
            </tr>
        </ItemTemplate>
        <LayoutTemplate>
            <table id="Table2" runat="server">
                <tr id="Tr1" runat="server">
                    <td id="Td1" runat="server">
                        <table ID="itemPlaceholderContainer" runat="server" border="0" class="table_ds_loai_tl">
                            <tr id="Tr2" runat="server" style="">
                                
                                <th id="Th1" runat="server">
                                    Mã</th>
                                <th id="Th2" runat="server">
                                    Tên (tiếng Việt)</th>
                                <th id="Th3" runat="server">
                                    Tên (tiếng Anh)</th>
                                <th id="Th4" runat="server">
                                    Thuộc về</th>
                              
                                <th id="Th5" runat="server" style="width: 15%">Công cụ
                                    </th>
                            </tr>
                            <tr ID="itemPlaceholder" runat="server">
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr id="Tr3" runat="server">
                    <td id="Td2" runat="server" style="">
                         <asp:DataPager ID="DataPager1" runat="server">
                            <Fields>
                                <asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True" 
                                    ShowNextPageButton="False" ShowPreviousPageButton="False" />
                                <asp:NumericPagerField/>
                                <asp:NextPreviousPagerField ButtonType="Button" ShowLastPageButton="True" 
                                    ShowNextPageButton="False" ShowPreviousPageButton="False" />
                            </Fields>
                        </asp:DataPager>
                    </td>
                </tr>
            </table>
        </LayoutTemplate>
        <SelectedItemTemplate>
            <tr style="">
                <td>
                    
                </td>
                <td>
                    <asp:Label ID="IDLoaiTLLabel" runat="server" Text='<%# Eval("IDLoaiTL") %>' />
                </td>
                <td>
                    <asp:Label ID="TenLoaiTLLabel" runat="server" 
                        Text='<%# Eval("TenLoaiTL") %>' />
                </td>
                <td>
                    <asp:Label ID="IDLoaiTLChaLabel" runat="server" 
                        Text='<%# Eval("IDLoaiTLCha") %>' />
                </td>
                <td>
                    <asp:Label ID="ThuTuHienThiLabel" runat="server" 
                        Text='<%# Eval("ThuTuHienThi") %>' />
                </td>
                <td>
                    <asp:Label ID="LoaiCopyLabel" runat="server" Text='<%# Eval("LoaiCopy") %>' />
                </td>
                <td>
                    <asp:Label ID="TenLoaiTL_enLabel" runat="server" 
                        Text='<%# Eval("TenLoaiTL_en") %>' />
                </td>
            </tr>
        </SelectedItemTemplate>
        
    </asp:ListView>
    
    
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
        SelectCommand="SELECT [IDLoaiTL], [TenLoaiTL], [TenLoaiTL_en], (SELECT b2.[TenLoaiTL] FROM [LoaiTaiLieu] b2 WHERE b2.[IDLoaiTL] = b1.[IDLoaiTLCha]) as IDLoaiTLCha,  [ThuTuHienThi], [LoaiCopy] FROM [LoaiTaiLieu] b1 ORDER BY [ThuTuHienThi]"
        ConflictDetection="OverwriteChanges" 
        InsertCommand="INSERT INTO [LoaiTaiLieu] ([TenLoaiTL], [TenLoaiTL_en], [IDLoaiTLCha], [ThuTuHienThi], [LoaiCopy]) VALUES (@TenLoaiTL, @TenLoaiTL_en, @IDLoaiTLCha, @ThuTuHienThi, @LoaiCopy)" 
        OldValuesParameterFormatString="original_{0}" 
        
        UpdateCommand="UPDATE [LoaiTaiLieu] SET [TenLoaiTL] = @TenLoaiTL, [TenLoaiTL_en] = @TenLoaiTL_en, [IDLoaiTLCha] = @IDLoaiTLCha, [ThuTuHienThi] = @ThuTuHienThi, [LoaiCopy] = @LoaiCopy WHERE [IDLoaiTL] = @original_IDLoaiTL AND (([TenLoaiTL] = @original_TenLoaiTL) OR ([TenLoaiTL] IS NULL AND @original_TenLoaiTL IS NULL)) AND (([TenLoaiTL_en] = @original_TenLoaiTL_en) OR ([TenLoaiTL_en] IS NULL AND @original_TenLoaiTL_en IS NULL)) AND (([IDLoaiTLCha] = @original_IDLoaiTLCha) OR ([IDLoaiTLCha] IS NULL AND @original_IDLoaiTLCha IS NULL)) AND (([ThuTuHienThi] = @original_ThuTuHienThi) OR ([ThuTuHienThi] IS NULL AND @original_ThuTuHienThi IS NULL)) AND (([LoaiCopy] = @original_LoaiCopy) OR ([LoaiCopy] IS NULL AND @original_LoaiCopy IS NULL))" 
        DeleteCommand="DELETE FROM [LoaiTaiLieu] WHERE [IDLoaiTL] = @original_IDLoaiTL">
        <DeleteParameters>
            <asp:Parameter Name="original_IDLoaiTL" Type="Int32" />
            <asp:Parameter Name="original_TenLoaiTL" Type="String" />
            <asp:Parameter Name="original_TenLoaiTL_en" Type="String" />
            <asp:Parameter Name="original_IDLoaiTLCha" Type="String" />
            <asp:Parameter Name="original_ThuTuHienThi" Type="Int32" />
            <asp:Parameter Name="original_LoaiCopy" Type="Int32" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="TenLoaiTL" Type="String" />
            <asp:Parameter Name="TenLoaiTL_en" Type="String" />
            <asp:Parameter Name="IDLoaiTLCha" Type="Int32" />
            <asp:Parameter Name="ThuTuHienThi" Type="Int32" />
            <asp:Parameter Name="LoaiCopy" Type="Int32" />
        </InsertParameters>
        <UpdateParameters>
            <asp:Parameter Name="TenLoaiTL" Type="String" />
            <asp:Parameter Name="TenLoaiTL_en" Type="String" />
            <asp:Parameter Name="IDLoaiTLCha" Type="Int32" />
            <asp:Parameter Name="ThuTuHienThi" Type="Int32" />
            <asp:Parameter Name="LoaiCopy" Type="Int32" />
            <asp:Parameter Name="original_IDLoaiTL" Type="Int32" />
            <asp:Parameter Name="original_TenLoaiTL" Type="String" />
            <asp:Parameter Name="original_TenLoaiTL_en" Type="String" />
            <asp:Parameter Name="original_IDLoaiTLCha" Type="Int32" />
            <asp:Parameter Name="original_ThuTuHienThi" Type="Int32" />
            <asp:Parameter Name="original_LoaiCopy" Type="Int32" />
        </UpdateParameters>
    </asp:SqlDataSource>

</asp:Content>

